package com.py.gs.businese.chatcheck;

public class ChatCheckTools2 {
	private boolean[] chars = new boolean[(int)Character.MAX_VALUE];
	
	public boolean checkSimilarity(String checkStr, String sourceStr) {
		if (checkStr.length() < 10 || sourceStr.length() < 10) {
			return false;
		}
		for (int i = 0; i < sourceStr.length(); i++) {
			chars[sourceStr.charAt(i)] = true;
		}
		int matchCount = 0;
		for (int i = 0; i < checkStr.length(); i++) {
			if (chars[checkStr.charAt(i)]) {
				matchCount++;
				if (matchCount > checkStr.length() / 2 || (matchCount + checkStr.length() - i - 1) < (checkStr.length() / 2)) {
					break;
				}
			}
		}
		//清空chars数据
		for (int i = 0; i < sourceStr.length(); i++) {
			chars[sourceStr.charAt(i)] = false;
		}
		return matchCount > checkStr.length() / 2;
	}
}
